from  celery import  Celery
import  random,redis
from  ronglian_sms_sdk import  SmsSDK

app=Celery('ssst',broker='redis://:123@127.0.0.1:6379/4',backend="redis://:123@127.0.0.1:6379/5")


accId = '8a216da882f1f59401835463b6491132'
accToken = 'ad8f510c3adb43cd947fce2e105763e1'
appId = '8a216da882f1f59401835463b7481139'


app.autodiscover_tasks(['seest'])

@app .task
def send_message(mobile):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'  # 容联云分配的一个测试短信验证码模版
    data=random.randint(100000,999999)
    r=redis.Redis(host='127.0.0.1',password='123',port=6379,db=5)
    r.set(mobile,data,ex=1200)
    datas = (data,5)
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    return  resp